<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>12_entends_prototype01</title>
	<meta name="author" content="Stark" />
	<!-- Date: 2018-10-20 -->
	<script type="text/javascript">
		var Person;
		(function(){
			// name在函数结束后就消失，在外面是无法引用的
			var name = "";
			Person = function(value){
				name = value;
			}
			Person.prototype.setName = function(value) {
				name = value;
			}
			Person.prototype.getName = function() {
				return name;
			}
		})();
		
		var p1 = new Person("aa");
		alert(p1.getName());
		p1.setName("bb");
		alert(p1.getName());
	</script>
</head>
<body>

</body>
</html>

